/** 
  国际学术会议审核列表
*/
<template>
    <div>
        <div v-if="ifShowList === 1">
            <condition-card
                @reset="reset"
                @search="onSubmit"
                label-position="right"
                label-width="150px"
            >
                <el-row :gutter="24" style="height: 50px;">
                    <el-col :span="8">
                        <el-form-item label="学院">
                            <el-select
                                v-model.trim="queryForm.condition.faculty"
                                clearable
                                style="width: 100%"
                                filterable
                                disabled
                                @change="changeCollege"
                            >
                                <el-option
                                    v-for="item in options.faculty"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value"
                                ></el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item label="专业">
                            <el-select
                                v-model.trim="queryForm.condition.profession"
                                clearable
                                style="width: 100%"
                            >
                                <el-option
                                    v-for="item in options.profession"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value"
                                ></el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item label="学号">
                            <el-input
                                v-model.trim="queryForm.condition.studentId"
                                maxlength="40"
                                clearable
                                class="topic-input-select"
                                placeholder="请输入"
                            ></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>

                <el-row :gutter="24" style="height: 50px;">
                    <el-col :span="8">
                        <el-form-item label="姓名">
                            <el-input
                                v-model.trim="queryForm.condition.studentName"
                                maxlength="40"
                                clearable
                                class="topic-input-select"
                                placeholder="请输入"
                            ></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item label="会议级别">
                            <el-select
                                v-model.trim="queryForm.condition.conferenceLevel"
                                clearable
                                style="width: 100%"
                            >
                                <el-option
                                    v-for="item in options.conferenceLevel"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value"
                                ></el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item label="会议审核状态">
                            <el-select
                                v-model.trim="queryForm.condition.approveStatus"
                                clearable
                                style="width: 100%"
                            >
                                <el-option
                                    v-for="item in options.approveStatus"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value"
                                ></el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row :gutter="24" style="height: 50px;">
                    <el-col :span="8">
                        <el-form-item label="报销审核状态">
                            <el-select
                                v-model.trim="queryForm.condition.reimbursementStatus"
                                clearable
                                style="width: 100%"
                            >
                                <el-option
                                    v-for="item in options.reimbursementStatus"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value"
                                ></el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                </el-row>
            </condition-card>
            <el-card shadow="never" v-loading="loading" body-style="padding: 24px;">
                <h1 class="condition-title">国际学术会议审核列表</h1>
                <div class="sub-title">
                    <div class="float-left">
                        <el-input
                            v-model.trim="queryForm.condition.conferenceCnOrEn"
                            placeholder="会议名称"
                            style="width:250px"
                            @keyup.enter.native="onSubmit"
                        >
                            <i
                                slot="suffix"
                                class="el-icon-search"
                                style="margin-top:10px;cursor:pointer"
                                @click="onSubmit"
                            ></i>
                        </el-input>
                    </div>
                    <div class="float-right" style="display: flex;">
                        <el-dropdown @command="batchExport">
                            <el-button type="primary">
                                批量下载附件
                                <i class="el-icon-arrow-down el-icon--right"></i>
                            </el-button>
                            <el-dropdown-menu slot="dropdown">
                                <el-dropdown-item command="1">出国申请</el-dropdown-item>
                                <el-dropdown-item command="2">回国报销</el-dropdown-item>
                            </el-dropdown-menu>
                        </el-dropdown>
                        <el-button type="primary" @click="openContent('pass')" v-show="ifPass">通过</el-button>
                        <el-button v-show="ifRefuse" @click="openContent('refuse')">不通过</el-button>
                        <el-button v-show="ifReturn" @click="openContent('return')">驳回</el-button>
                        <el-button @click="exportConference('advance')">高级导出</el-button>
                        <el-button @click="exportConference('export')">导出</el-button>
                        <el-button @click="exportConference('rev')">回国报销导出</el-button>
                    </div>
                </div>
                <edu-table
                    :pagination="false"
                    :order="true"
                    :tooltipEffect="tooltipEffect"
                    stripe
                    :data="dataList"
                    size="small"
                    @selection-change="handleSelectionChange"
                >
                    <edu-table-column label="学号" prop="studentId" align="center"></edu-table-column>
                    <edu-table-column label="姓名" prop="studentName" align="center"></edu-table-column>
                    <edu-table-column label="学院" prop="facultyName" align="center"></edu-table-column>
                    <edu-table-column label="专业" prop="professionName" align="center"></edu-table-column>
                    <edu-table-column
                        label="国际会议英文名称"
                        prop="englishName"
                        min-width="150"
                        align="center"
                    ></edu-table-column>
                    <edu-table-column
                        label="国际会议英文名称（缩写）"
                        prop="englishNameAbbreviation"
                        min-width="190"
                    ></edu-table-column>
                    <edu-table-column label="国际会议中文名称" prop="name" min-width="150" align="center"></edu-table-column>
                    <edu-table-column label="会议级别" prop="conferenceLevel">
                        <template slot-scope="scope">{{scope.row.conferenceLevel | meeting}}</template>
                    </edu-table-column>
                    <edu-table-column
                        label="会议开始时间"
                        prop="conferenceStartTime"
                        min-width="120"
                        align="center"
                    ></edu-table-column>
                    <edu-table-column
                        label="会议结束时间"
                        prop="conferenceEndTime"
                        min-width="120"
                        align="center"
                    ></edu-table-column>
                    <edu-table-column
                        label="实际出国时间"
                        prop="realLeaveTime"
                        min-width="120"
                        align="center"
                    ></edu-table-column>
                    <edu-table-column
                        label="实际回国时间"
                        prop="realBackTime"
                        min-width="120"
                        align="center"
                    ></edu-table-column>
                    <edu-table-column
                        label="会议审核状态"
                        prop="approveStatus"
                        min-width="120"
                        align="center"
                    >
                        <template slot-scope="scope">
                            <el-tag
                                v-if="scope.row.approveStatus !== null"
                                :type="scope.row.approveStatus | getType"
                            >{{scope.row.approveStatus | approveStatus}}</el-tag>
                        </template>
                    </edu-table-column>
                    <edu-table-column
                        label="下一级审批人"
                        prop="approverName"
                        min-width="120"
                        align="center"
                    ></edu-table-column>
                    <edu-table-column label="操作" prop="idCard" min-width="180" align="center">
                        <template slot-scope="scope">
                            <el-button type="text" @click="toDetail(scope.row, 'view')">查看</el-button>
                            <el-button
                                type="text"
                                v-show="scope.row.canApprove && approveRev"
                                @click="toDetail(scope.row, 'approve')"
                            >审核</el-button>
                            <el-button
                                type="text"
                                v-show="(scope.row.approveStatus === 3 && downSub)"
                                @click="exportSubsidize(scope.row)"
                            >下载资助函</el-button>
                        </template>
                    </edu-table-column>
                    <edu-table-column
                        label="报销审核状态"
                        prop="reimbursementStatus"
                        min-width="120"
                        align="center"
                    >
                        <template slot-scope="scope">
                            <el-tag
                                v-if="scope.row.reimbursementStatus !==null"
                                :type="scope.row.reimbursementStatus | getType"
                            >{{scope.row.reimbursementStatus | reimbursementStatus}}</el-tag>
                        </template>
                    </edu-table-column>
                    <edu-table-column
                        label="报销下一级审批人"
                        prop="reimbursementApproverName"
                        min-width="150"
                        align="center"
                    ></edu-table-column>
                    <edu-table-column label="回国报销操作" prop="idCard" min-width="180" align="center">
                        <template slot-scope="scope">
                            <el-button
                                type="text"
                                v-show="scope.row.reimbursementStatus !== null"
                                @click="editCon(scope.row, 'view')"
                            >查看</el-button>
                            <el-button
                                type="text"
                                v-show="scope.row.reimbursementCanApprove && reimburRev"
                                @click="editCon(scope.row, 'approve')"
                            >审核</el-button>
                        </template>
                    </edu-table-column>
                </edu-table>
                <el-row type="flex" class="row-bg" justify="end">
                    <el-col>
                        <el-pagination
                            @size-change="handleSizeChange"
                            @current-change="handleCurrentChange"
                            :current-page="queryForm.pageNum_"
                            :page-sizes="[20, 40, 80, 100]"
                            :page-size="queryForm.pageSize_"
                            layout="total, sizes, prev, pager, next, jumper"
                            :total="queryForm.total_"
                            style="float:right;margin-top:10px"
                        ></el-pagination>
                    </el-col>
                </el-row>
            </el-card>
        </div>
        <!-- 申请 审核、查看页面 -->
        <div v-if="ifShowList ===2">
            <audit-Page-OfCon
                @returnVal="changekey"
                :studentInfo="studentInfo"
                :pgConferenceApply="pgConferenceApply"
                :pgExchangeHistory="pgExchangeHistory"
                :approveHistory="approveHistory"
                :file="file"
                :submitType="submitType"
                :countryList="countryList"
                :actNo="actNo"
                :pageFrom="pageFrom"
                :reimbursementId="reimbursementId"
            ></audit-Page-OfCon>
        </div>
        <!-- 报销页面 -->
        <div v-if="ifShowList ===3">
            <audit-Pro-Rep-And-Exp-Rei
                @returnVal="changekey"
                :tranParm="tranParm"
                :ifAudit="ifAudit"
                :pageFrom="pageFrom"
            ></audit-Pro-Rep-And-Exp-Rei>
        </div>
        <el-dialog
            title="审核意见"
            :visible.sync="dialogFormVisible"
            :close-on-click-modal="false"
            :close-on-press-escape="false"
        >
            <el-form ref="contentForm" :model="contentForm">
                <el-form-item label="审批说明" prop="content" v-show="returnContent">
                    <el-input
                        type="textarea"
                        :rows="4"
                        placeholder="请输入内容"
                        maxlength="500"
                        v-model="contentForm.content"
                    ></el-input>
                </el-form-item>
                <el-form-item label="审批说明" prop="contentT" v-show="!returnContent">
                    <el-input
                        type="textarea"
                        :rows="4"
                        placeholder="请输入内容"
                        maxlength="500"
                        v-model="contentForm.contentT"
                    ></el-input>
                </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button @click="closeContent">取 消</el-button>
                <el-button type="primary" @click="auditRevT">确 定</el-button>
            </div>
        </el-dialog>
        <edu-export-dialog :title="$t('message.prompt')" ref="downloadRef"></edu-export-dialog>
    </div>
</template>
<script>
import auditPageOfCon from './auditPageOfCon'
import auditProRepAndExpRei from './auditProRepAndExpRei'
import revOfInterAcaConApi from 'common/src/api/internationalCommunication/revOfInterAcaCon'
import appListOfIntAcaConApi from 'common/src/api/internationalCommunication/appListOfIntAcaCon'
import { queryDic } from 'common/src/api/dictionary'
import baseUrl from 'common/src/api/internationalCommunication/env'
import UTILS from 'common/src/utils/utils'
export default {
    components: {
        'audit-Page-OfCon': auditPageOfCon,
        'audit-Pro-Rep-And-Exp-Rei': auditProRepAndExpRei
    },
    data() {
        return {
            queryForm: {
                pageNum_: 1,
                pageSize_: 20,
                total_: 0,
                condition: {
                    faculty: '',
                    profession: '',
                    studentId: '',
                    studentName: '',
                    conferenceLevel: '',
                    approveStatus: '',
                    reimbursementStatus: '',
                    conferenceCnOrEn: ''
                }
            },
            countryList: {
                country: []
            },
            dialogFormVisible: false,
            tranParm: {
                conferenceStartTime: '',
                conferenceEndTime: '',
                id: '',
                studentId: '',
                submitType: '',
                reimbursementActNo: '',
                reimbursementId: '',
                realReadPosterTime: '',
                realReadPosterSubject: ''
            },
            ifShowList: 1,
            studentInfo: {},
            auths: [],
            queryFaculty: '',
            downSub: false,
            pageFrom: '',
            approveRev: false,
            reimburRev: false,
            ifReturn: false,
            ifPass: false,
            ifRefuse: false,
            pgConferenceApply: {},
            pgExchangeHistory: [],
            approveHistory: [],
            auditRev: '',
            ifAudit: '',
            actNo: '',
            reimbursementId: '',
            file: [],
            submitType: '',
            dataList: [],
            returnContent: true,
            multipleSelection: [],
            contentForm: {
                content: '',
                contentT: ''
            },
            options: {
                conferenceLevel: [
                    { value: 1, label: '顶级会议' },
                    { value: 2, label: 'A类会议' },
                    { value: 3, label: 'B类会议' }
                ],
                faculty: [],
                profession: [],
                approveStatus: [
                    {
                        label: '已提交',
                        value: 1
                    },
                    {
                        label: '待审核',
                        value: 2
                    },
                    {
                        label: '通过',
                        value: 3
                    },
                    {
                        label: '不通过',
                        value: 5
                    }
                ],
                reimbursementStatus: [
                    {
                        label: '已提交',
                        value: 1
                    },
                    {
                        label: '待审核',
                        value: 2
                    },
                    {
                        label: '通过',
                        value: 3
                    }
                ]
            }
        }
    },

    created() {
        this.getListData()
        this.initOptions()

        if (localStorage.getItem('sessiondata')) {
            // 获取当前用户auths权限
            if (JSON.parse(localStorage.getItem('sessiondata')).auths) {
                this.auths = JSON.parse(localStorage.getItem('sessiondata')).auths
            }
            // 获取登陆用户学院
            if (JSON.parse(localStorage.getItem('sessiondata')).mockUser) {
                this.queryFaculty = JSON.parse(localStorage.getItem('sessiondata')).mockUser.faculty
                this.queryForm.condition.faculty = this.queryFaculty

                this.changeCollege(this.queryForm.condition.faculty)
            } else if (JSON.parse(localStorage.getItem('sessiondata')).user) {
                this.queryFaculty = JSON.parse(localStorage.getItem('sessiondata')).user.faculty
                this.queryForm.condition.faculty = this.queryFaculty
                this.changeCollege(this.queryForm.condition.faculty)
            }
        }
        // this.getRecommendRole()
    },
    filters: {
        meeting(val) {
            switch (val) {
                case 1:
                    return '顶级会议 '
                case 2:
                    return 'A类会议 '
                case 3:
                    return 'B类会议 '
                default:
                    return ' '
            }
        },
        approveStatus(val) {
            switch (val) {
                case 1:
                    return '已提交'
                case 2:
                    return '待审核'
                case 3:
                    return '通过'
                case 5:
                    return '不通过'
                default:
                    return ' '
            }
        },
        getType(val) {
            switch (val) {
                case 0:
                    return 'info'
                case 1:
                    return 'info'
                case 2:
                    return 'info'
                case 3:
                    return 'success'
                case 4:
                    return 'warning'
                case 5:
                    return 'danger'
                default:
                    return val
            }
        },
        reimbursementStatus(val) {
            switch (val) {
                case 1:
                    return '已提交'
                case 2:
                    return '待审核'
                case 3:
                    return '通过'
                default:
                    return ' '
            }
        }
    },
    methods: {
        async initOptions() {
            // 筛选条件字典查询
            let data = {
                lang: this.$store.getters.language || 'cn',
                type: 'allChild',
                keys: [
                    'X_YX' // 学院
                ]
            }
            await queryDic(data).then(res => {
                UTILS.fillSelect(
                    {
                        faculty: 'X_YX' // 学院
                    },
                    res.data,
                    this.options
                )
            })
        },

        // 修改学院
        changeCollege(val) {
            this.options.profession = []
            this.queryForm.condition.profession = ''
            let data = {
                lang: this.$store.getters.language || 'cn',
                type: 'allChild',
                keys: ['G_ZY'],
                filter: {
                    prefix: [val],
                    specilaCode: 'XY2ZY',
                    facultys: [val]
                }
            }
            queryDic(data).then(res => {
                UTILS.fillSelect(
                    {
                        profession: 'G_ZY' // 专业
                    },
                    res.data,
                    this.options
                )
            })
        },

        // getRecommendRole() {
        //     let _this = this
        //     revOfInterAcaConApi.recommendRole().then(res => {
        //         if (res.code === 200) {
        //             if (res.data.leader && res.data.leader > 0) {
        //                 _this.ifLeader = true
        //                 _this.ifPrincipal = false
        //                 _this.ifTeacher = false
        //             } else if (res.data.principal && res.data.principal > 0) {
        //                 _this.ifPrincipal = true
        //                 _this.ifTeacher = false
        //             } else if (res.data.teacher && res.data.teacher > 0) {
        //                 _this.ifTeacher = true
        //             }
        //         }
        //     })
        // },

        // 审核-查看页返回
        changekey(val) {
            this.ifShowList = val
            this.getListData()
        },
        // 跳转申请查看 审核页
        toDetail(row, val) {
            this.getDetail(row.id)
            this.reimbursementId = row.reimbursementId
            this.actNo = row.actNo
            this.ifShowList = 2
            this.pageFrom = 'rev'
            this.submitType = val
        },

        // 跳转报销查看 审核页
        editCon(row, val) {
            this.ifShowList = 3
            this.ifAudit = val
            this.pageFrom = 'rev'
            this.setParm(row)
        },

        // 报销传参
        setParm(row) {
            this.tranParm.conferenceEndTime = row.conferenceEndTime
            this.tranParm.conferenceStartTime = row.conferenceStartTime
            this.tranParm.realReadPosterTime = row.realReadPosterTime
            this.tranParm.realReadPosterSubject = row.realReadPosterSubject
            this.tranParm.id = row.id
            this.tranParm.studentId = row.studentId
            this.tranParm.reimbursementId = row.reimbursementId
            this.tranParm.reimbursementActNo = row.reimbursementActNo
            this.tranParm.submitType = 'view'
        },

        async getCountry() {
            // 筛选条件字典查询
            let data = {
                lang: this.$store.getters.language || 'cn',
                type: 'allChild',
                keys: [
                    'G_GJQU' // 国家/地区
                ]
            }
            await queryDic(data).then(res => {
                UTILS.fillSelect(
                    {
                        country: 'G_GJQU' // 国家/地区
                    },
                    res.data,
                    this.countryList
                )
            })
        },

        // 获取申请信息
        async getDetail(id) {
            let _this = this
            await _this.getCountry()
            appListOfIntAcaConApi.getConferenceDetails(id).then(res => {
                if (res.data.studentInfo) {
                    _this.studentInfo = res.data.studentInfo
                }
                if (res.data.pgConferenceApply) {
                    _this.pgConferenceApply = res.data.pgConferenceApply
                }
                if (res.data.pgExchangeHistory) {
                    _this.pgExchangeHistory = res.data.pgExchangeHistory
                }
                if (res.data.approveHistory) {
                    _this.approveHistory = res.data.approveHistory
                }
                if (res.data.file) {
                    _this.file = res.data.file
                }
            })
        },

        // 下载资助函
        exportSubsidize(row) {
            appListOfIntAcaConApi.exportSubsidize(row.id).then(res => {
                this.$message({
                    message: '下载成功',
                    type: 'success'
                })
            })
        },
        // 关闭弹框
        closeContent() {
            this.dialogFormVisible = false
        },

        // 打开弹框
        openContent(lsStatus) {
            let _this = this
            this.contentForm.content = ''
            this.contentForm.contentT = ''
            this.status = ''
            let approve = ''
            let disApprove = ''
            let reimbur = ''
            let disReimbur = ''
            let stop = false
            if (lsStatus === 'pass' || lsStatus === 'refuse') {
                _this.returnContent = false
            } else if (lsStatus === 'return') {
                _this.returnContent = true
            }

            _this.status = lsStatus
            if (_this.multipleSelection.length === 0) {
                _this.$message.error('请勾选数据')
                return
            } else if (_this.multipleSelection) {
                _this.multipleSelection.forEach(val => {
                    // 判断 出国审批的数据是否全是本人待审核的
                    if (val.canApprove) {
                        // 申请审批
                        if (val.approveStatus === 2 && val.reimbursementStatus === null) {
                            approve = 'exist'
                            // 判断出国申请是否有不同状态数据
                        } else if (val.approveStatus !== 2 && val.reimbursementStatus === null) {
                            disApprove = 'exist'
                        }

                        // 判断 出国审批的数据是否全是本人待审核的
                    } else if (val.reimbursementCanApprove) {
                        // 报销审批
                        if (val.approveStatus === 3 && val.reimbursementStatus === 2) {
                            reimbur = 'exist'

                            // 判断报销是否有不同状态数据
                        } else if (val.approveStatus === 3 && val.reimbursementStatus !== 2) {
                            disReimbur = 'exist'
                        }
                    } else {
                        stop = true
                    }
                })
            }

            if (stop) {
                _this.$message.error('当前勾选存在不可审核数据')
                return
            } else if (approve && reimbur) {
                _this.$message.error('审核类型不同，不能批量操作')
                return
            } else if (approve && !disApprove) {
                _this.dialogFormVisible = true
            } else if (reimbur && !disReimbur) {
                // 回国报销 不能批量不通过
                if (_this.status === 'refuse') {
                    _this.$message.error('回国报销审核不可进行不通过操作')
                    return
                } else if (_this.status === 'pass' || _this.status === 'return') {
                    _this.dialogFormVisible = true
                }
            } else {
                _this.$message.error('您只能审核待审核状态数据')
                return
            }
        },

        // 批量操作
        auditRevT() {
            let _this = this
            let approve = ''
            let flag = false
            let disApprove = ''
            let reimbur = ''
            let disReimbur = ''
            let parm = []
            let revParm = {
                workFlowReview: [],
                refuseType: null
            }
            let stop = false
            let contentVal = ''
            if (_this.status === 'pass' || _this.status === 'refuse') {
                contentVal = _this.contentForm.contentT
                flag = true
            } else if (_this.status === 'return') {
                if (_this.contentForm.content) {
                    contentVal = _this.contentForm.content
                    flag = true
                } else {
                    flag = false
                    _this.$message.error(`审批说明不可为空`)
                }
            } else {
                return false
            }
            if (flag) {
                _this.multipleSelection.forEach(val => {
                    // 判断 出国审批的数据是否全是本人待审核的
                    if (val.canApprove) {
                        // 申请审批
                        if (val.approveStatus === 2 && val.reimbursementStatus === null) {
                            approve = 'exist'
                            if (_this.status === 'pass') {
                                parm.push({
                                    no: val.actNo,
                                    content: contentVal
                                })
                            } else if (_this.status === 'refuse') {
                                revParm.workFlowReview.push({
                                    no: val.actNo,
                                    content: contentVal
                                })
                                revParm.refuseType = 1
                            } else if (_this.status === 'return') {
                                revParm.workFlowReview.push({
                                    no: val.actNo,
                                    content: contentVal
                                })
                                revParm.refuseType = 0
                            }

                            // 判断出国申请是否有不同状态数据
                        } else if (val.approveStatus !== 2 && val.reimbursementStatus === null) {
                            disApprove = 'exist'
                        }

                        // 判断 出国审批的数据是否全是本人待审核的
                    } else if (val.reimbursementCanApprove) {
                        // 报销审批
                        if (val.approveStatus === 3 && val.reimbursementStatus === 2) {
                            reimbur = 'exist'
                            parm.push({
                                no: val.reimbursementActNo,
                                content: contentVal
                            })
                            // 判断报销是否有不同状态数据
                        } else if (val.approveStatus === 3 && val.reimbursementStatus !== 2) {
                            disReimbur = 'exist'
                        }
                    } else {
                        stop = true
                    }
                })

                if (approve && !disApprove) {
                    // 出国申请通过
                    if (_this.status === 'pass') {
                        revOfInterAcaConApi.approveAgree(parm).then(res => {
                            if (res.code === 200) {
                                _this.$message({
                                    message: '出国申请审核成功',
                                    type: 'success'
                                })
                                _this.dialogFormVisible = false
                                _this.getListData()
                            }
                        })
                        // 出国申请 不通过 驳回
                    } else if (_this.status === 'refuse' || _this.status === 'return') {
                        revOfInterAcaConApi.approveRefuse(revParm).then(res => {
                            if (res.code === 200) {
                                _this.$message({
                                    message: '审核成功',
                                    type: 'success'
                                })
                                _this.dialogFormVisible = false
                                _this.getListData()
                            }
                        })
                    }
                } else if (reimbur && !disReimbur) {
                    // 回国报销通过
                    if (_this.status === 'pass') {
                        revOfInterAcaConApi.conApproveAgree(parm).then(res => {
                            if (res.code === 200) {
                                _this.$message({
                                    message: '回国报销审核成功',
                                    type: 'success'
                                })
                                _this.dialogFormVisible = false
                                _this.getListData()
                            }
                        })
                        // 回国报销驳回
                    } else if (_this.status === 'return') {
                        revOfInterAcaConApi.conApproveRefuse(parm).then(res => {
                            if (res.code === 200) {
                                _this.$message({
                                    message: '审核成功',
                                    type: 'success'
                                })
                                _this.dialogFormVisible = false
                                _this.getListData()
                            }
                        })
                    }
                }
            }
        },

        // 批量下载附件
        batchExport(command) {
            let _this = this
            let parm = {
                faculty: this.queryForm.condition.faculty,
                profession: this.queryForm.condition.profession,
                studentId: this.queryForm.condition.studentId,
                studentName: this.queryForm.condition.studentName,
                conferenceLevel: this.queryForm.condition.conferenceLevel,
                approveStatus: this.queryForm.condition.approveStatus,
                reimbursementStatus: this.queryForm.condition.reimbursementStatus,
                conferenceCnOrEn: this.queryForm.condition.conferenceCnOrEn,
                type: Number(command),
                ids: []
            }
            if (_this.multipleSelection) {
                _this.multipleSelection.forEach(val => {
                    parm.ids.push(val.id)
                })
            }

            if (_this.dataList.length === 0) {
                _this.$message.error('无数据')
            } else {
                revOfInterAcaConApi.getFilePath(parm).then(resM => {
                    if (resM.data.length === 0) {
                        _this.$message.error('无可下载附件')
                        return
                    } else {
                        _this.$refs.downloadRef.open()
                        revOfInterAcaConApi
                            .batchExport(resM.data)
                            .then(res => {
                                if (res.code === 200) {
                                    revOfInterAcaConApi
                                        .exportConferenceT(res.data.key)
                                        .then(resT => {
                                            if (
                                                res.code === 200 &&
                                                resT &&
                                                resT.data &&
                                                resT.data.path
                                            ) {
                                                let path =
                                                    `${baseUrl}/export/exportZip?path=` +
                                                    resT.data.path
                                                window.open(path)
                                                _this.$message({
                                                    message: '下载成功',
                                                    type: 'success'
                                                })
                                                this.$refs.downloadRef.close()
                                            } else {
                                                _this.batchExportNext(res.data.key)
                                            }
                                        })
                                }
                            })
                            .catch(err => {
                                this.$refs.downloadRef.close()
                            })
                    }
                })
            }
        },
        // 批量下载 轮询
        batchExportNext(val) {
            let _this = this
            setTimeout(() => {
                revOfInterAcaConApi.exportConferenceT(val).then(resT => {
                    if (resT && resT.data && resT.data.path) {
                        let path = `${baseUrl}/export/exportZip?path=` + resT.data.path
                        window.open(path)
                        _this.$message({
                            message: '下载成功',
                            type: 'success'
                        })
                        this.$refs.downloadRef.close()
                    } else {
                        _this.batchExportNext(val)
                    }
                })
            }, 3000)
        },

        // 导出
        exportConference(exportType) {
            let _this = this
            let parm = {
                faculty: this.queryForm.condition.faculty,
                profession: this.queryForm.condition.profession,
                studentId: this.queryForm.condition.studentId,
                studentName: this.queryForm.condition.studentName,
                conferenceLevel: this.queryForm.condition.conferenceLevel,
                approveStatus: this.queryForm.condition.approveStatus,
                reimbursementStatus: this.queryForm.condition.reimbursementStatus,
                conferenceCnOrEn: this.queryForm.condition.conferenceCnOrEn,
                roleType: '1',
                ids: []
            }

            if (_this.multipleSelection) {
                _this.multipleSelection.forEach(val => {
                    parm.ids.push(val.id)
                })
            }
            let flag = false
            if (this.multipleSelection.length > 0) {
                this.multipleSelection.forEach(sel => {
                    if (sel.reimbursementStatus !== null) {
                        flag = true
                    }
                })
            } else {
                flag = true
            }
            if (_this.dataList.length === 0) {
                _this.$message.error('无数据')
            } else if (flag === false && exportType === 'rev') {
                _this.$message.error('所勾选的数据均无回国报销申请')
            } else {
                _this.$refs.downloadRef.open()
                if (exportType === 'export') {
                    revOfInterAcaConApi
                        .exportConference(parm)
                        .then(res => {
                            if (res.code === 200) {
                                revOfInterAcaConApi.exportConferenceT(res.data.key).then(resT => {
                                    if (resT.code == 200 && resT.data.path) {
                                        revOfInterAcaConApi
                                            .exportExcelT(resT.data.path)
                                            .then(resS => {
                                                _this.$message({
                                                    message: '导出成功',
                                                    type: 'success'
                                                })
                                                this.$refs.downloadRef.close()
                                            })
                                    } else {
                                        _this.exportNext(res.data.key, exportType)
                                    }
                                })
                            }
                        })
                        .catch(err => {
                            this.$refs.downloadRef.close()
                        })
                } else if (exportType === 'advance') {
                    revOfInterAcaConApi
                        .advanceExport(parm)
                        .then(res => {
                            if (res.code === 200) {
                                revOfInterAcaConApi.exportConferenceT(res.data.key).then(resT => {
                                    if (resT.code == 200 && resT.data.path) {
                                        revOfInterAcaConApi
                                            .exportExcelT(resT.data.path)
                                            .then(resS => {
                                                _this.$message({
                                                    message: '高级导出成功',
                                                    type: 'success'
                                                })
                                                this.$refs.downloadRef.close()
                                            })
                                    } else {
                                        _this.exportNext(res.data.key, exportType)
                                    }
                                })
                            }
                        })
                        .catch(err => {
                            this.$refs.downloadRef.close()
                        })
                } else if (exportType === 'rev' && flag) {
                    _this.exportNext(parm, exportType)
                }
            }
        },
        // 导出接口轮询
        exportNext(val, exportType) {
            let _this = this
            setTimeout(() => {
                if (exportType === 'rev') {
                    revOfInterAcaConApi.downExcel(val).then(resM => {
                        if (resM.code === 200 && resM.data) {
                            let path = `${baseUrl}/pgIntlConference/downloadFile?path=` + resM.data
                            window.open(path)
                            _this.$message({
                                message: '回国报销导出成功',
                                type: 'success'
                            })
                            this.$refs.downloadRef.close()
                        } else {
                            _this.exportNext(val, exportType)
                        }
                    })
                } else {
                    revOfInterAcaConApi.exportConferenceT(val).then(resT => {
                        if (resT.data.path) {
                            revOfInterAcaConApi.exportExcelT(resT.data.path).then(resS => {
                                if (exportType === 'advance') {
                                    _this.$message({
                                        message: '高级导出成功',
                                        type: 'success'
                                    })
                                } else if (exportType === 'export') {
                                    _this.$message({
                                        message: '导出成功',
                                        type: 'success'
                                    })
                                }

                                this.$refs.downloadRef.close()
                            })
                        } else {
                            _this.exportNext(val, exportType)
                        }
                    })
                }
            }, 3000)
        },

        reset() {
            this.queryForm = {
                pageNum_: 1,
                pageSize_: 20,
                total_: 0,
                condition: {
                    faculty: this.queryFaculty,
                    profession: '',
                    studentId: '',
                    studentName: '',
                    conferenceLevel: '',
                    approveStatus: '',
                    reimbursementStatus: '',
                    conferenceCnOrEn: ''
                }
            }
            this.getListData()
        },
        onSubmit() {
            this.queryForm.pageNum_ = 1
            this.queryForm.total_ = 0
            this.queryForm.pageSize_ = 20
            this.getListData()
        },
        getListData() {
            let _this = this
            this.dataList = []
            revOfInterAcaConApi.getApproveList(this.queryForm).then(res => {
                res.data.list.forEach(revList => {
                    _this.dataList.push(revList)
                    _this.queryForm.total_ = res.data.total_
                    _this.queryForm.pageSize_ = res.data.pageSize_
                    _this.queryForm.pageNum_ = res.data.pageNum_
                })
            })
            this.multipleSelection = []
        },
        handleSelectionChange(val) {
            this.multipleSelection = val
        },
        handleSizeChange(val) {
            this.queryForm.pageSize_ = val
            this.getListData()
        },
        handleCurrentChange(val) {
            this.queryForm.pageNum_ = val
            this.getListData()
        }
    },
    watch: {
        auths: {
            handler(newVal) {
                if (newVal && Array.isArray(newVal) && newVal.length > 0) {
                    newVal.some(item => {
                        // 下载资助函
                        if (item.authCode === 'interAca-tempSet-downSub') {
                            this.downSub = true
                        }
                        // 出国申请审核
                        if (item.authCode === 'interAca-tempSet-approveRev') {
                            this.approveRev = true
                        }
                        // 回国报销审核
                        if (item.authCode === 'interAca-tempSet-reimburRev') {
                            this.reimburRev = true
                        }
                        // 批量通过
                        if (item.authCode === 'interAca-tempSet-ifPass') {
                            this.ifPass = true
                        }
                        // 批量拒绝
                        if (item.authCode === 'interAca-tempSet-ifRefuse') {
                            this.ifRefuse = true
                        }
                        // 批量驳回
                        if (item.authCode === 'interAca-tempSet-ifReturn') {
                            this.ifReturn = true
                        }
                    })
                }
            },
            deep: true,
            immediate: true
        }
    }
}
</script>
<style lang="scss" scoped>
.condition-card ::v-deep {
    .el-row {
        height: 30px !important;
    }
    .el-form-item {
        margin-bottom: 0 !important;
    }
}
.roster-container ::v-deep {
    .el-date-editor--datetimerange.el-input__inner {
        width: 100% !important;
    }
    .el-form {
        padding-right: 15px;
    }
}
.condition-title {
    color: #2b3b4e;
    font-size: 18px;
    line-height: 24px;
    font-weight: bold;
}
.sub-title {
    margin: 16px 0 65px 0;
    font-size: 16px;
    color: #000020;
    letter-spacing: 0;
}
</style>